var oSl = document.getElementsByClassName('search-label')[0];
var aList = oSl.getElementsByTagName('li')[0];
var aList1 = oSl.getElementsByTagName('li')[1];
var aList2 = oSl.getElementsByTagName('li')[2];
var aList3 = oSl.getElementsByTagName('li')[3];
var aDd = aList.getElementsByTagName('dd');
var aA1 = aList1.getElementsByTagName('a');
var aA2 = aList2.getElementsByTagName('a');
var aA3 = aList3.getElementsByTagName('a');
var oP = document.getElementsByClassName('cart-clear')[0];

//可选可删
for(i = 0; i < aA1.length; i++){
    aA1[i].onclick = function () {
        for (j = 0; j < aA1.length; j++) {
            aA1[j].style = 'border:none; color: #000';
        }
        this.style = 'border :1px #999 solid; color: #e01222';
        var oDd = aList.getElementsByTagName('dd')[0];
        if (this !== aA1[0]) {
            aList.style.display = 'block';
            oDd.innerHTML = '<a>' + this.innerHTML + ' ×</a>';
            var oA = oDd.getElementsByTagName('a')[0];
            oA.onclick = function () {
                oDd.removeChild(oA);
                for (j = 0; j < aA1.length; j++) {
                    aA1[j].style = 'border:none; color: #000';
                }
                aA1[0].style = 'border :1px #999 solid; color: #e01222';
                if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                    aList.style.display = 'none';
                }
            };
        } else {
            var oA = oDd.getElementsByTagName('a')[0];
            oDd.removeChild(oA);
            if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                aList.style.display = 'none';
            }
        }
    };
}
for(i = 0; i < aA2.length; i++){
    aA2[i].onclick = function () {
        for (j = 0; j < aA2.length; j++) {
            aA2[j].style = 'border:none; color: #000';
        }
        this.style = 'border :1px #999 solid; color: #e01222';
        var oDd = aList.getElementsByTagName('dd')[1];
        if (this != aA2[0]) {
            aList.style.display = 'block';
            oDd.innerHTML = '<a>' + this.innerHTML + ' ×</a>';
            var oA = oDd.getElementsByTagName('a')[0];
            oA.onclick = function () {
                oDd.removeChild(oA);
                for (j = 0; j < aA2.length; j++) {
                    aA2[j].style = 'border:none; color: #000';
                }
                aA2[0].style = 'border :1px #999 solid; color: #e01222';
                if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                    aList.style.display = 'none';
                }
            };
        } else {
            var oA = oDd.getElementsByTagName('a')[0];
            oDd.removeChild(oA);
            if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                aList.style.display = 'none';
            }
        }
    };
}
for(i = 0; i < aA3.length; i++){
    aA3[i].onclick = function () {
        for (j = 0; j < aA3.length; j++) {
            aA3[j].style = 'border:none; color: #000';
        }
        this.style = 'border :1px #999 solid; color: #e01222';
        var oDd = aList.getElementsByTagName('dd')[2];
        if (this != aA3[0]) {
            aList.style.display = 'block';
            oDd.innerHTML = '<a>' + this.innerHTML + ' ×</a>';
            var oA = oDd.getElementsByTagName('a')[0];
            oA.onclick = function () {
                oDd.removeChild(oA);
                for (j = 0; j < aA3.length; j++) {
                    aA3[j].style = 'border:none; color: #000';
                }
                aA3[0].style = 'border :1px #999 solid; color: #e01222';
                if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                    aList.style.display = 'none';
                }
            };
        } else {
            var oA = oDd.getElementsByTagName('a')[0];
            oDd.removeChild(oA);
            if(!(aDd[0].childNodes.length>0)&&!(aDd[1].childNodes.length>0)&&!(aDd[2].childNodes.length>0)){
                aList.style.display = 'none';
            }
        }
    };
}

//点击清除全清
oP.onclick = function () {
    aList.style.display = 'none';
    for (j = 0; j < aA1.length; j++) {
        aA1[j].style = 'border:none; color: #000';
    }
    for (j = 0; j < aA2.length; j++) {
        aA2[j].style = 'border:none; color: #000';
    }
    for (j = 0; j < aA3.length; j++) {
        aA3[j].style = 'border:none; color: #000';
    }
    aA1[0].style = 'border :1px #999 solid; color: #e01222';
    aA2[0].style = 'border :1px #999 solid; color: #e01222';
    aA3[0].style = 'border :1px #999 solid; color: #e01222';
    var oA1 = aDd[0].getElementsByTagName('a')[0];
    var oA2 = aDd[1].getElementsByTagName('a')[0];
    var oA3 = aDd[2].getElementsByTagName('a')[0];
    aDd[0].removeChild(oA1);
    aDd[1].removeChild(oA2);
    aDd[2].removeChild(oA3);
};

//侧栏
var oSide = document.getElementsByClassName('side')[0];
var oPer = document.getElementById('per');
var oMy = document.getElementById('MY');
var aP = oMy.getElementsByTagName('p');
var aLi = oSide.getElementsByTagName('li');
var oSpan = oSide.getElementsByClassName('side-span')[0];
aLi[0].onmouseover=function(){
    oPer.style.display='block';
    aLi[0].getElementsByTagName('img')[0].src = 'img/search/side_1r.png';
};
oPer.onmouseover=function(){
    oPer.style.display='block';
};
aLi[0].onmouseout=oPer.onmouseout=function(){
    oPer.style.display='none';
    aLi[0].getElementsByTagName('img')[0].src = 'img/search/side_1.png';
};
aLi[1].onmouseover=function(){
    oSpan.style.backgroundColor='#ffffff';
    oSpan.style.color='#e01222';
    aLi[1].getElementsByTagName('img')[0].src = 'img/search/side_2r.png';
};
aLi[1].onmouseout=function(){
    oSpan.style.backgroundColor='#e01222';
    oSpan.style.color='#ffffff';
    aLi[1].getElementsByTagName('img')[0].src = 'img/search/side_2.png';
};
aLi[2].onmouseover=function(){
    aLi[2].getElementsByTagName('img')[0].src = 'img/search/side_3r.png';
    aP[0].style.display='block';
};
aLi[2].onmouseout=function(){
    aLi[2].getElementsByTagName('img')[0].src = 'img/search/side_3.png';
    aP[0].style.display='none';
};
aLi[3].onmouseover=function(){
    aLi[3].getElementsByTagName('img')[0].src = 'img/search/side_4r.png';
    aP[1].style.display='block';
};
aLi[3].onmouseout=function(){
    aLi[3].getElementsByTagName('img')[0].src = 'img/search/side_4.png';
    aP[1].style.display='none';
};
aLi[4].onmouseover=function(){
    aP[2].style.display='block';
};
aLi[4].onmouseout=function(){
    aP[2].style.display='none';
};
aLi[5].onmouseover=function(){
    aLi[5].getElementsByTagName('img')[0].src = 'img/search/side_6r.png';
    aP[3].style.display='block';
};
aLi[5].onmouseout=function(){
    aLi[5].getElementsByTagName('img')[0].src = 'img/search/side_6.png';
    aP[3].style.display='none';
};
aLi[6].onmouseover=function(){
    aLi[6].getElementsByTagName('img')[0].src = 'img/search/side_7r.png';
    aP[4].style.display='block';
};
aLi[6].onmouseout=function(){
    aLi[6].getElementsByTagName('img')[0].src = 'img/search/side_7.png';
    aP[4].style.display='none';
};
aLi[7].onmouseover=function(){
    aP[5].style.display='block';
};
aLi[7].onmouseout=function(){
    aP[5].style.display='none';
};
aLi[8].onclick=function () {
    document.body.scrollTop = document.documentElement.scrollTop = 0;
};